

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Add Constraints [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Constraint,Constraint On States, Debugger Generation Of Sequence Diagrams,Constraint Operators On,State,State Constraints, Debugger Generation Of Sequence Diagrams,Sequence Diagram,Sequence Diagram Constraints On States, Debugger Generation Of Diagrams,Operators,Operators On Constraints">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Add Constraints</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="create_a_state_machine.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="xunit_testing.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">The State </span><span class="f_UIControl">Properties</span><span class="f_BodyText"> dialog below is for the State </span><span class="f_BodyText" style="font-style: italic;">Turquoise</span><span class="f_BodyText">. The </span><span class="f_UIControl">Constraints</span><span class="f_BodyText"> tab is open to show how the State is linked to the Class </span><span class="f_BodyText" style="font-style: italic;">Painter</span><span class="f_BodyText">. A State can be defined by a single constraint or by many; in the example below the State </span><span class="f_BodyText" style="font-style: italic;">Turquoise</span><span class="f_BodyText"> has two constraints.</span></p>
<p class="p_TextIndentedL2"><img src="state%20constraints%20-%20turquoise.png" width="385" height="562" border="0" alt="State Constraints - Turquoise"></p>
<p class="p_BodyText"><span class="f_BodyText">The</span><span class="f_BodyText" style="font-style: italic;"> Painter</span><span class="f_BodyText"> Class has a member called </span><span class="f_BodyText" style="font-style: italic;">Paint</span><span class="f_BodyText"> of type </span><span class="f_BodyText" style="font-style: italic;">Ccolour.</span><span class="f_BodyText"> The </span><span class="f_BodyText" style="font-style: italic;">Paint</span><span class="f_BodyText"> member has two member variables called </span><span class="f_BodyText" style="font-style: italic;">primary</span><span class="f_BodyText"> and </span><span class="f_BodyText" style="font-style: italic;">secondary</span><span class="f_BodyText">. These variables are enums. The values of constraints can only be compared for </span><span class="f_BodyText" style="font-style: italic;">elemental, enum</span><span class="f_BodyText"> and </span><span class="f_BodyText" style="font-style: italic;">string</span><span class="f_BodyText"> types. In native code, equivalence of Class objects is only possible for pointer types.</span></p>
<p class="p_BodyText"><span class="f_BodyText">What this constraint means is:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">when an instance of the </span><span class="f_Bulletlist1" style="font-style: italic;">Painter</span><span class="f_Bulletlist1"> Class exists and</span></li>
<li><a name="constr"></a><span class="f_Bulletlist1">its member variable </span><span class="f_Bulletlist1" style="font-style: italic;">Paint'</span><span class="f_Bulletlist1">s member variable </span><span class="f_Bulletlist1" style="font-style: italic;">primary</span><span class="f_Bulletlist1"> has the </span><span class="f_Bulletlist1" style="font-style: italic;">enum</span><span class="f_Bulletlist1"> value </span><span class="f_MenuKeyField">Blue</span><span class="f_Bulletlist1"> and</span></li>
<li><span class="f_Bulletlist1">the member variable </span><span class="f_Bulletlist1" style="font-style: italic;">secondary</span><span class="f_Bulletlist1"> has the </span><span class="f_Bulletlist1" style="font-style: italic;">enum</span><span class="f_Bulletlist1"> value</span><span class="f_MenuKeyField"> Green</span><span class="f_Bulletlist1"> then</span></li>
<li><span class="f_Bulletlist1">this State is evaluated to</span><span class="f_MenuKeyField"> true</span><span class="f_Bulletlist1">.</span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">You can see the member variables for these constraints in the following illustration of the Class </span><span class="f_BodyText" style="font-style: italic;">Painter,</span><span class="f_BodyText"> expanded to show members. Notice the enumeration </span><span class="f_BodyText" style="font-style: italic;">TColor</span><span class="f_BodyText"> values. These are the values tested in the constraints in the State </span><span class="f_UIControl">Properties</span><span class="f_BodyText"> dialog above.</span></p>
<p class="p_TextIndentedL2"><img src="painter%20-%20members.png" width="220" height="333" border="0" alt="Painter - Members"></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Operators in Constraints</span></p>
<p class="p_BodyText"><span class="f_BodyText">There are two types of operators you can use on constraints to define a State:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">Logical operators </span><span class="f_Bulletlist1">AND</span><span class="f_Bulletlist1"> and </span><span class="f_Bulletlist1">OR</span><span class="f_Bulletlist1"> can be used to combine constraints</span></li>
<li><span class="f_Bulletlist1">Equivalence operators {</span><span class="f_Bulletlist1">=</span><span class="f_Bulletlist1"> and</span><span class="f_Bulletlist1"> !=</span><span class="f_Bulletlist1">} can be used to define the conditions of a constraint.</span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">All the constraints for a State are subject to an AND operation unless otherwise specified. You can use the OR operation on them instead, so you could rewrite the constraints in the <a href="add_constraints.htm#constr">earlier example</a> as:</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_Code"><span class="f_Code">Paint.primary=Blue OR</span></p>
<p class="p_Code"><span class="f_Code">Paint.secondary=Green</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_BodyText"><span class="f_BodyText">Below are some examples of using the equivalence operators:</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_Code"><span class="f_Code">Paint.primary!=Blue AND</span></p>
<p class="p_Code"><span class="f_Code">Paint.secondary!=Green</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_Code"><span class="f_Code">Paint.primary=Blue OR</span></p>
<p class="p_Code"><span class="f_Code">Paint.primary=Green</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_Code"><span class="f_Code">Person.FirstName=John</span></p>
<p class="p_Code"><span class="f_Code">Person.LastName=Carpenter</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="952" bgcolor="#efeff7" style="width:952px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="952" bgcolor="#f7f7ff" style="width:952px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">Quotes around strings are optional. The comparison for strings is always case-sensitive in determining the truth of a constraint.</span></p>
</td>
</tr>
</table>
</div>




            </div>
          </div>
        </div>



</div>


</body>
</html>
